package cn.kwq.project_manger.pojo.dto;

import cn.kwq.project_manger.pojo.Project;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import java.util.Date;
import java.util.List;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "新增 比赛/项目 请求对象")
public class AddProJDto {
    @ApiModelProperty(value = "主键，传了就是修改，没传就是新增(新增还是更改就看这个字段)")
    private String projectId;

    @ApiModelProperty(value = "项目标题（名字）")
    private String projectName;

    @ApiModelProperty(value = "报名开始时间")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date startTime;

    @ApiModelProperty(value = "报名结束时间")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date endTime;

    @ApiModelProperty("地点 / 项目来源")
    private String place;

    /**
     * 发起活动的组织/部门
     */
    @ApiModelProperty(value = "发起活动的组织/部门")
    private String createDepartment;


    @ApiModelProperty(value = "标签（str集合）比赛不传，项目的话就传")
    private List<String> tags;

    /**
     * 比赛1项目0
     */
    @ApiModelProperty(value = "类型： 比赛1 项目0")
    private String type;

    /**
     * 学院类型 文0理1无要求2
     */
    @ApiModelProperty(value = "学院类型 文0理1无要求2")
    private String instituteType;


    @ApiModelProperty(value = "专业限制（没有就不传）")
    private String  majorLimit;

    @ApiModelProperty("内容 / 项目类型")
    private String content;

    @ApiModelProperty("规则 / 项目范围")
    private String rule;

    @ApiModelProperty("奖励 / 项目投资金额")
    private String reward;

    @ApiModelProperty("加入方式")
    private String enterWay;

    @ApiModelProperty("发布者联系方式")
    private String connectPublisher;

    @ApiModelProperty("简介/项目介绍")
    private String briefly;//简介

    @ApiModelProperty("开始时间")
    @Temporal(TemporalType.DATE)
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date projectStartTime;

    @ApiModelProperty("结束时间")
    @Temporal(TemporalType.DATE)
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date projectEndTime;

    @ApiModelProperty("发布人姓名")
    private String createName;

    @ApiModelProperty("项目自定义的字符串")
    private String projectStr;



    public Project getProject(){
        return
        Project.builder()
                .projectId(this.projectId==null ? null : Long.valueOf(this.projectId))
                .projectName(this.projectName)
                .startTime(this.startTime)
                .endTime(this.endTime)
                .projectStartTime(this.projectStartTime)
                .projectEndTime(this.projectEndTime)
                .place(this.place)
                .instituteType(this.instituteType==null ? null: Integer.valueOf(this.instituteType))
                .createDepartment(this.createDepartment)
                .type(this.type==null? null: Integer.valueOf(this.type))
                .briefly(this.briefly)
                .majorLimit(this.majorLimit)
                .content(this.content)
                .rule(this.rule)
                .reward(this.reward)
                .enterWay(this.enterWay)
                .connectPublisher(this.connectPublisher)
                .createName(this.createName)
                .status(null)
                .build();
    }


}
